<?php

namespace ezswoole\table;

use EasySwoole\Spl\SplBean;
use EasySwoole\Spl\SplString;
use ezswoole\table\TableField;
/**
 *
 * Copyright  FaShop
 * License    http://www.fashop.cn
 * link       http://www.fashop.cn
 * Created by FaShop.
 * User: hanwenbo
 * Date: 2021/10/6
 * Time: 12:44 上午
 *
 */
class Table extends SplBean
{
	public function __construct( array $data = null, $autoCreateProperty = false )
	{
		$_data = [];
		if( $data['tableColumns'] ){
			$tableColumns = [];
			foreach( $data['tableColumns'] as $c ){
				$tableColumns[$c['Field']] = new TableField( $c );
			}
			$_data = ['tableColumns' => $tableColumns];
		}
		foreach( $data as $key => $value ){
			$str           = new SplString( $key );
			$field         = $str->lower()->camel()->__toString();
			$_data[$field] = $value;
		}
		parent::__construct( $_data, $autoCreateProperty );
	}

	protected $tableName;

	protected $tableComment;

	protected $tableColumns;

	/**
	 * @return mixed
	 */
	public function getTableColumns()
	{
		return $this->tableColumns;
	}

	/**
	 * @param mixed $tableColumns
	 */
	public function setTableColumns( $tableColumns ) : void
	{
		$this->tableColumns = $tableColumns;
	}



	/**
	 * @return mixed
	 */
	public function getTableComment()
	{
		return $this->tableComment;
	}

	/**
	 * @param mixed $tableComment
	 */
	public function setTableComment( $tableComment ) : void
	{
		$this->tableComment = $tableComment;
	}


	/**
	 * @return mixed
	 */
	public function getTableName()
	{
		return $this->tableName;
	}

	/**
	 * @param mixed $tableName
	 */
	public function setTableName( $tableName ) : void
	{
		$this->tableName = $tableName;
	}


}